package com.wmada.toolkit.ffmpeg;

import com.wmada.toolkit.ffmpeg.prop.MediaInfo;
import com.wmada.toolkit.ffmpeg.prop.MediaInfoParser;
import com.wmada.toolkit.rpc.CmdExecuteException;
import com.wmada.toolkit.rpc.CmdParseException;

/**
 * @author will.ma
 * @date 2020-11-3
 */
public class Ffmpeg {

    public static MediaInfo getMediaInfo(Source source) throws CmdParseException, CmdExecuteException {
        FfmpegExecutor  executor = new FfmpegExecutor("ffprobe");
        MediaInfoParser parser   = new MediaInfoParser();

        executor.setLogLevel("level+info").json().addArgs("-show_streams").addArgs("-i", source.getPath()).execute(parser);

        return parser.getResult();
    }

}
